package com.byb.server.service.mapper;

import com.byb.server.domain.*;
import com.byb.server.service.dto.ExpertOpinionDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity ExpertOpinion and its DTO ExpertOpinionDTO.
 */
@Mapper(componentModel = "spring", uses = {ProductMapper.class, })
public interface ExpertOpinionMapper extends EntityMapper <ExpertOpinionDTO, ExpertOpinion> {

    @Mapping(source = "product.id", target = "productId")
    @Mapping(source = "product.productName", target = "productProductName")
    ExpertOpinionDTO toDto(ExpertOpinion expertOpinion); 

    @Mapping(source = "productId", target = "product")
    ExpertOpinion toEntity(ExpertOpinionDTO expertOpinionDTO); 
    default ExpertOpinion fromId(Long id) {
        if (id == null) {
            return null;
        }
        ExpertOpinion expertOpinion = new ExpertOpinion();
        expertOpinion.setId(id);
        return expertOpinion;
    }
}
